<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时间练习</title>
    <script>
        var flag=false;
        function f() {
            var light=document.getElementById("light");
            if (flag){
                light.src="1.png";
                flag=false;
            }else{
                light.src="2" +
                    ".png";
                flag=true;
            }
        }
    </script>
</head>
<body>
<input id="light" type="image" src="1.png" onclick="f()">
</body>
</html>